﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace 学生成绩查询及选课系统.admin
{
    public partial class classManage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            GridView1.DataSourceID = "SqlDataSource1";
            GridView1.DataBind();
        }

        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Insert")
            {
                GridView1.DataSourceID = null;
                GridView1.DataBind();
            }
        }

        protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
        {
            GridView1.DataSourceID = "SqlDataSource1";
            GridView1.DataBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = TextBox1.Text;
            if (name == "")
            {
                SqlDataSource1.SelectCommand = "SELECT * FROM [class]";
                GridView1.DataBind();
                return;
            }
            SqlDataSource1.SelectCommand = "SELECT * FROM [class] where [classno] like '%" + name + "%'";
            GridView1.DataSourceID = "SqlDataSource1";
            GridView1.DataBind();
        }
    }
}